<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span class="hs-cpp">
#if __GLASGOW_HASKELL__ &gt;= 702
</span><span class="hs-pragma">{-# LANGUAGE Safe #-}</span><span class="hs-cpp">
#endif
</span><span class="hs-cpp">#if __GLASGOW_HASKELL__ &gt;= 710
</span><span class="hs-pragma">{-# LANGUAGE AutoDeriveTypeable #-}</span><span class="hs-cpp">
#endif
</span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- Module      :  Control.Monad.Trans.State.Strict</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Copyright   :  (c) Andy Gill 2001,</span><span>
</span><span id="line-12"></span><span class="hs-comment">--                (c) Oregon Graduate Institute of Science and Technology, 2001</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- License     :  BSD-style (see the file LICENSE)</span><span>
</span><span id="line-14"></span><span class="hs-comment">--</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- Maintainer  :  R.Paterson@city.ac.uk</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- Stability   :  experimental</span><span>
</span><span id="line-17"></span><span class="hs-comment">-- Portability :  portable</span><span>
</span><span id="line-18"></span><span class="hs-comment">--</span><span>
</span><span id="line-19"></span><span class="hs-comment">-- Strict state monads, passing an updatable state through a computation.</span><span>
</span><span id="line-20"></span><span class="hs-comment">-- See below for examples.</span><span>
</span><span id="line-21"></span><span class="hs-comment">--</span><span>
</span><span id="line-22"></span><span class="hs-comment">-- Some computations may not require the full power of state transformers:</span><span>
</span><span id="line-23"></span><span class="hs-comment">--</span><span>
</span><span id="line-24"></span><span class="hs-comment">-- * For a read-only state, see &quot;Control.Monad.Trans.Reader&quot;.</span><span>
</span><span id="line-25"></span><span class="hs-comment">--</span><span>
</span><span id="line-26"></span><span class="hs-comment">-- * To accumulate a value without using it on the way, see</span><span>
</span><span id="line-27"></span><span class="hs-comment">--   &quot;Control.Monad.Trans.Writer&quot;.</span><span>
</span><span id="line-28"></span><span class="hs-comment">--</span><span>
</span><span id="line-29"></span><span class="hs-comment">-- In this version, sequencing of computations is strict (but computations</span><span>
</span><span id="line-30"></span><span class="hs-comment">-- are not strict in the state unless you force it with 'seq' or the like).</span><span>
</span><span id="line-31"></span><span class="hs-comment">-- For a lazy version with the same interface, see</span><span>
</span><span id="line-32"></span><span class="hs-comment">-- &quot;Control.Monad.Trans.State.Lazy&quot;.</span><span>
</span><span id="line-33"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-34"></span><span>
</span><span id="line-35"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Control.Monad.Trans.State.Strict</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-36"></span><span>    </span><span class="annot"><span class="hs-comment">-- * The State monad</span></span><span>
</span><span id="line-37"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#State"><span class="hs-identifier">State</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-38"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#state"><span class="hs-identifier">state</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-39"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#runState"><span class="hs-identifier">runState</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-40"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#evalState"><span class="hs-identifier">evalState</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-41"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#execState"><span class="hs-identifier">execState</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-42"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#mapState"><span class="hs-identifier">mapState</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-43"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#withState"><span class="hs-identifier">withState</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-44"></span><span>    </span><span class="annot"><span class="hs-comment">-- * The StateT monad transformer</span></span><span>
</span><span id="line-45"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier">StateT</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-46"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#evalStateT"><span class="hs-identifier">evalStateT</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-47"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#execStateT"><span class="hs-identifier">execStateT</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-48"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#mapStateT"><span class="hs-identifier">mapStateT</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-49"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#withStateT"><span class="hs-identifier">withStateT</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-50"></span><span>    </span><span class="annot"><span class="hs-comment">-- * State operations</span></span><span>
</span><span id="line-51"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#get"><span class="hs-identifier">get</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-52"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#put"><span class="hs-identifier">put</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-53"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#modify"><span class="hs-identifier">modify</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-54"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#modify%27"><span class="hs-identifier">modify'</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-55"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#gets"><span class="hs-identifier">gets</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-56"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Lifting other operations</span></span><span>
</span><span id="line-57"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#liftCallCC"><span class="hs-identifier">liftCallCC</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-58"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#liftCallCC%27"><span class="hs-identifier">liftCallCC'</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-59"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#liftCatch"><span class="hs-identifier">liftCatch</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-60"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#liftListen"><span class="hs-identifier">liftListen</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-61"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#liftPass"><span class="hs-identifier">liftPass</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-62"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Examples</span></span><span>
</span><span id="line-63"></span><span>    </span><span class="annot"><span class="hs-comment">-- ** State monads</span></span><span>
</span><span id="line-64"></span><span>    </span><span class="annot"><span class="hs-comment">-- $examples</span></span><span>
</span><span id="line-65"></span><span>
</span><span id="line-66"></span><span>    </span><span class="annot"><span class="hs-comment">-- ** Counting</span></span><span>
</span><span id="line-67"></span><span>    </span><span class="annot"><span class="hs-comment">-- $counting</span></span><span>
</span><span id="line-68"></span><span>
</span><span id="line-69"></span><span>    </span><span class="annot"><span class="hs-comment">-- ** Labelling trees</span></span><span>
</span><span id="line-70"></span><span>    </span><span class="annot"><span class="hs-comment">-- $labelling</span></span><span>
</span><span id="line-71"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-72"></span><span>
</span><span id="line-73"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.IO.Class.html#"><span class="hs-identifier">Control.Monad.IO.Class</span></a></span><span>
</span><span id="line-74"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Control.Monad.Signatures.html"><span class="hs-identifier">Control.Monad.Signatures</span></a></span><span>
</span><span id="line-75"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Class.html"><span class="hs-identifier">Control.Monad.Trans.Class</span></a></span><span class="hs-cpp">
#if MIN_VERSION_base(4,12,0)
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Functor.Contravariant.html#"><span class="hs-identifier">Data.Functor.Contravariant</span></a></span><span class="hs-cpp">
#endif
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Functor.Identity.html#"><span class="hs-identifier">Data.Functor.Identity</span></a></span><span>
</span><span id="line-80"></span><span>
</span><span id="line-81"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Applicative.html#"><span class="hs-identifier">Control.Applicative</span></a></span><span>
</span><span id="line-82"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span class="hs-cpp">
#if MIN_VERSION_base(4,9,0)
</span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.Fail.html#"><span class="hs-identifier">Control.Monad.Fail</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Fail</span></span><span class="hs-cpp">
#endif
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.Fix.html#"><span class="hs-identifier">Control.Monad.Fix</span></a></span><span>
</span><span id="line-87"></span><span>
</span><span id="line-88"></span><span class="hs-comment">-- ---------------------------------------------------------------------------</span><span>
</span><span id="line-89"></span><span class="hs-comment">-- | A state monad parameterized by the type @s@ of the state to carry.</span><span>
</span><span id="line-90"></span><span class="hs-comment">--</span><span>
</span><span id="line-91"></span><span class="hs-comment">-- The 'return' function leaves the state unchanged, while @&gt;&gt;=@ uses</span><span>
</span><span id="line-92"></span><span class="hs-comment">-- the final state of the first computation as the initial state of</span><span>
</span><span id="line-93"></span><span class="hs-comment">-- the second.</span><span>
</span><span id="line-94"></span><span class="hs-keyword">type</span><span> </span><span id="State"><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#State"><span class="hs-identifier hs-var">State</span></a></span></span><span> </span><span id="local-6989586621679081758"><span class="annot"><a href="#local-6989586621679081758"><span class="hs-identifier hs-type">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081758"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="../../base/src/Data.Functor.Identity.html#Identity"><span class="hs-identifier hs-type">Identity</span></a></span><span>
</span><span id="line-95"></span><span>
</span><span id="line-96"></span><span class="hs-comment">-- | Construct a state monad computation from a function.</span><span>
</span><span id="line-97"></span><span class="hs-comment">-- (The inverse of 'runState'.)</span><span>
</span><span id="line-98"></span><span id="local-6989586621679082031"><span id="local-6989586621679082032"><span id="local-6989586621679082033"><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#state"><span class="hs-identifier hs-type">state</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679082033"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-99"></span><span>      </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679082032"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679082031"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621679082032"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- ^pure state transformer</span><span>
</span><span id="line-100"></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679082032"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679082033"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679082031"><span class="hs-identifier hs-type">a</span></a></span></span></span></span><span>   </span><span class="hs-comment">-- ^equivalent state-passing computation</span><span>
</span><span id="line-101"></span><span id="state"><span class="annot"><span class="annottext">state :: forall (m :: * -&gt; *) s a. Monad m =&gt; (s -&gt; (a, s)) -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#state"><span class="hs-identifier hs-var hs-var">state</span></a></span></span><span> </span><span id="local-6989586621679081755"><span class="annot"><span class="annottext">s -&gt; (a, s)
</span><a href="#local-6989586621679081755"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(s -&gt; m (a, s)) -&gt; StateT s m a
forall s (m :: * -&gt; *) a. (s -&gt; m (a, s)) -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-var">StateT</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(a, s) -&gt; m (a, s)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">((a, s) -&gt; m (a, s)) -&gt; (s -&gt; (a, s)) -&gt; s -&gt; m (a, s)
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">s -&gt; (a, s)
</span><a href="#local-6989586621679081755"><span class="hs-identifier hs-var">f</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-102"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#state"><span class="hs-pragma hs-type">state</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-103"></span><span>
</span><span id="line-104"></span><span class="hs-comment">-- | Unwrap a state monad computation as a function.</span><span>
</span><span id="line-105"></span><span class="hs-comment">-- (The inverse of 'state'.)</span><span>
</span><span id="line-106"></span><span id="local-6989586621679082018"><span id="local-6989586621679082019"><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#runState"><span class="hs-identifier hs-type">runState</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#State"><span class="hs-identifier hs-type">State</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679082019"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679082018"><span class="hs-identifier hs-type">a</span></a></span><span>   </span><span class="hs-comment">-- ^state-passing computation to execute</span><span>
</span><span id="line-107"></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679082019"><span class="hs-identifier hs-type">s</span></a></span><span>           </span><span class="hs-comment">-- ^initial state</span><span>
</span><span id="line-108"></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679082018"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621679082019"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span></span></span><span>      </span><span class="hs-comment">-- ^return value and final state</span><span>
</span><span id="line-109"></span><span id="runState"><span class="annot"><span class="annottext">runState :: forall s a. State s a -&gt; s -&gt; (a, s)
</span><a href="Control.Monad.Trans.State.Strict.html#runState"><span class="hs-identifier hs-var hs-var">runState</span></a></span></span><span> </span><span id="local-6989586621679081752"><span class="annot"><span class="annottext">State s a
</span><a href="#local-6989586621679081752"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Identity (a, s) -&gt; (a, s)
forall a. Identity a -&gt; a
</span><a href="../../base/src/Data.Functor.Identity.html#runIdentity"><span class="hs-identifier hs-var hs-var">runIdentity</span></a></span><span> </span><span class="annot"><span class="annottext">(Identity (a, s) -&gt; (a, s))
-&gt; (s -&gt; Identity (a, s)) -&gt; s -&gt; (a, s)
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">State s a -&gt; s -&gt; Identity (a, s)
forall s (m :: * -&gt; *) a. StateT s m a -&gt; s -&gt; m (a, s)
</span><a href="Control.Monad.Trans.State.Strict.html#runStateT"><span class="hs-identifier hs-var hs-var">runStateT</span></a></span><span> </span><span class="annot"><span class="annottext">State s a
</span><a href="#local-6989586621679081752"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-110"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#runState"><span class="hs-pragma hs-type">runState</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-111"></span><span>
</span><span id="line-112"></span><span class="hs-comment">-- | Evaluate a state computation with the given initial state</span><span>
</span><span id="line-113"></span><span class="hs-comment">-- and return the final value, discarding the final state.</span><span>
</span><span id="line-114"></span><span class="hs-comment">--</span><span>
</span><span id="line-115"></span><span class="hs-comment">-- * @'evalState' m s = 'fst' ('runState' m s)@</span><span>
</span><span id="line-116"></span><span id="local-6989586621679082011"><span id="local-6989586621679082012"><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#evalState"><span class="hs-identifier hs-type">evalState</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#State"><span class="hs-identifier hs-type">State</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679082012"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679082011"><span class="hs-identifier hs-type">a</span></a></span><span>  </span><span class="hs-comment">-- ^state-passing computation to execute</span><span>
</span><span id="line-117"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679082012"><span class="hs-identifier hs-type">s</span></a></span><span>          </span><span class="hs-comment">-- ^initial value</span><span>
</span><span id="line-118"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679082011"><span class="hs-identifier hs-type">a</span></a></span></span></span><span>          </span><span class="hs-comment">-- ^return value of the state computation</span><span>
</span><span id="line-119"></span><span id="evalState"><span class="annot"><span class="annottext">evalState :: forall s a. State s a -&gt; s -&gt; a
</span><a href="Control.Monad.Trans.State.Strict.html#evalState"><span class="hs-identifier hs-var hs-var">evalState</span></a></span></span><span> </span><span id="local-6989586621679081749"><span class="annot"><span class="annottext">State s a
</span><a href="#local-6989586621679081749"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621679081748"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081748"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(a, s) -&gt; a
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">State s a -&gt; s -&gt; (a, s)
forall s a. State s a -&gt; s -&gt; (a, s)
</span><a href="Control.Monad.Trans.State.Strict.html#runState"><span class="hs-identifier hs-var">runState</span></a></span><span> </span><span class="annot"><span class="annottext">State s a
</span><a href="#local-6989586621679081749"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081748"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-120"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#evalState"><span class="hs-pragma hs-type">evalState</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-121"></span><span>
</span><span id="line-122"></span><span class="hs-comment">-- | Evaluate a state computation with the given initial state</span><span>
</span><span id="line-123"></span><span class="hs-comment">-- and return the final state, discarding the final value.</span><span>
</span><span id="line-124"></span><span class="hs-comment">--</span><span>
</span><span id="line-125"></span><span class="hs-comment">-- * @'execState' m s = 'snd' ('runState' m s)@</span><span>
</span><span id="line-126"></span><span id="local-6989586621679082005"><span id="local-6989586621679082006"><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#execState"><span class="hs-identifier hs-type">execState</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#State"><span class="hs-identifier hs-type">State</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679082006"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679082005"><span class="hs-identifier hs-type">a</span></a></span><span>  </span><span class="hs-comment">-- ^state-passing computation to execute</span><span>
</span><span id="line-127"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679082006"><span class="hs-identifier hs-type">s</span></a></span><span>          </span><span class="hs-comment">-- ^initial value</span><span>
</span><span id="line-128"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679082006"><span class="hs-identifier hs-type">s</span></a></span></span></span><span>          </span><span class="hs-comment">-- ^final state</span><span>
</span><span id="line-129"></span><span id="execState"><span class="annot"><span class="annottext">execState :: forall s a. State s a -&gt; s -&gt; s
</span><a href="Control.Monad.Trans.State.Strict.html#execState"><span class="hs-identifier hs-var hs-var">execState</span></a></span></span><span> </span><span id="local-6989586621679081747"><span class="annot"><span class="annottext">State s a
</span><a href="#local-6989586621679081747"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621679081746"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081746"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(a, s) -&gt; s
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">State s a -&gt; s -&gt; (a, s)
forall s a. State s a -&gt; s -&gt; (a, s)
</span><a href="Control.Monad.Trans.State.Strict.html#runState"><span class="hs-identifier hs-var">runState</span></a></span><span> </span><span class="annot"><span class="annottext">State s a
</span><a href="#local-6989586621679081747"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081746"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-130"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#execState"><span class="hs-pragma hs-type">execState</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-131"></span><span>
</span><span id="line-132"></span><span class="hs-comment">-- | Map both the return value and final state of a computation using</span><span>
</span><span id="line-133"></span><span class="hs-comment">-- the given function.</span><span>
</span><span id="line-134"></span><span class="hs-comment">--</span><span>
</span><span id="line-135"></span><span class="hs-comment">-- * @'runState' ('mapState' f m) = f . 'runState' m@</span><span>
</span><span id="line-136"></span><span id="local-6989586621679081998"><span id="local-6989586621679081999"><span id="local-6989586621679082000"><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#mapState"><span class="hs-identifier hs-type">mapState</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679082000"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621679081999"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679081998"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621679081999"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#State"><span class="hs-identifier hs-type">State</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081999"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679082000"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#State"><span class="hs-identifier hs-type">State</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081999"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081998"><span class="hs-identifier hs-type">b</span></a></span></span></span></span><span>
</span><span id="line-137"></span><span id="mapState"><span class="annot"><span class="annottext">mapState :: forall a s b. ((a, s) -&gt; (b, s)) -&gt; State s a -&gt; State s b
</span><a href="Control.Monad.Trans.State.Strict.html#mapState"><span class="hs-identifier hs-var hs-var">mapState</span></a></span></span><span> </span><span id="local-6989586621679081745"><span class="annot"><span class="annottext">(a, s) -&gt; (b, s)
</span><a href="#local-6989586621679081745"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Identity (a, s) -&gt; Identity (b, s))
-&gt; StateT s Identity a -&gt; StateT s Identity b
forall (m :: * -&gt; *) a s (n :: * -&gt; *) b.
(m (a, s) -&gt; n (b, s)) -&gt; StateT s m a -&gt; StateT s n b
</span><a href="Control.Monad.Trans.State.Strict.html#mapStateT"><span class="hs-identifier hs-var">mapStateT</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(b, s) -&gt; Identity (b, s)
forall a. a -&gt; Identity a
</span><a href="../../base/src/Data.Functor.Identity.html#Identity"><span class="hs-identifier hs-var">Identity</span></a></span><span> </span><span class="annot"><span class="annottext">((b, s) -&gt; Identity (b, s))
-&gt; (Identity (a, s) -&gt; (b, s))
-&gt; Identity (a, s)
-&gt; Identity (b, s)
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(a, s) -&gt; (b, s)
</span><a href="#local-6989586621679081745"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">((a, s) -&gt; (b, s))
-&gt; (Identity (a, s) -&gt; (a, s)) -&gt; Identity (a, s) -&gt; (b, s)
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Identity (a, s) -&gt; (a, s)
forall a. Identity a -&gt; a
</span><a href="../../base/src/Data.Functor.Identity.html#runIdentity"><span class="hs-identifier hs-var hs-var">runIdentity</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-138"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#mapState"><span class="hs-pragma hs-type">mapState</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-139"></span><span>
</span><span id="line-140"></span><span class="hs-comment">-- | @'withState' f m@ executes action @m@ on a state modified by</span><span>
</span><span id="line-141"></span><span class="hs-comment">-- applying @f@.</span><span>
</span><span id="line-142"></span><span class="hs-comment">--</span><span>
</span><span id="line-143"></span><span class="hs-comment">-- * @'withState' f m = 'modify' f &gt;&gt; m@</span><span>
</span><span id="line-144"></span><span id="local-6989586621679081987"><span id="local-6989586621679081988"><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#withState"><span class="hs-identifier hs-type">withState</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679081988"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679081988"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#State"><span class="hs-identifier hs-type">State</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081988"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081987"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#State"><span class="hs-identifier hs-type">State</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081988"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081987"><span class="hs-identifier hs-type">a</span></a></span></span></span><span>
</span><span id="line-145"></span><span id="withState"><span class="annot"><span class="annottext">withState :: forall s a. (s -&gt; s) -&gt; State s a -&gt; State s a
</span><a href="Control.Monad.Trans.State.Strict.html#withState"><span class="hs-identifier hs-var hs-var">withState</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(s -&gt; s) -&gt; StateT s Identity a -&gt; StateT s Identity a
forall s (m :: * -&gt; *) a. (s -&gt; s) -&gt; StateT s m a -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#withStateT"><span class="hs-identifier hs-var">withStateT</span></a></span><span>
</span><span id="line-146"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#withState"><span class="hs-pragma hs-type">withState</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-147"></span><span>
</span><span id="line-148"></span><span class="hs-comment">-- ---------------------------------------------------------------------------</span><span>
</span><span id="line-149"></span><span class="hs-comment">-- | A state transformer monad parameterized by:</span><span>
</span><span id="line-150"></span><span class="hs-comment">--</span><span>
</span><span id="line-151"></span><span class="hs-comment">--   * @s@ - The state.</span><span>
</span><span id="line-152"></span><span class="hs-comment">--</span><span>
</span><span id="line-153"></span><span class="hs-comment">--   * @m@ - The inner monad.</span><span>
</span><span id="line-154"></span><span class="hs-comment">--</span><span>
</span><span id="line-155"></span><span class="hs-comment">-- The 'return' function leaves the state unchanged, while @&gt;&gt;=@ uses</span><span>
</span><span id="line-156"></span><span class="hs-comment">-- the final state of the first computation as the initial state of</span><span>
</span><span id="line-157"></span><span class="hs-comment">-- the second.</span><span>
</span><span id="line-158"></span><span class="hs-keyword">newtype</span><span> </span><span id="StateT"><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-var">StateT</span></a></span></span><span> </span><span id="local-6989586621679082027"><span class="annot"><a href="#local-6989586621679082027"><span class="hs-identifier hs-type">s</span></a></span></span><span> </span><span id="local-6989586621679082026"><span class="annot"><a href="#local-6989586621679082026"><span class="hs-identifier hs-type">m</span></a></span></span><span> </span><span id="local-6989586621679082025"><span class="annot"><a href="#local-6989586621679082025"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="StateT"><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-var">StateT</span></a></span></span><span> </span><span class="hs-special">{</span><span> </span><span id="runStateT"><span class="annot"><span class="annottext">forall s (m :: * -&gt; *) a. StateT s m a -&gt; s -&gt; m (a, s)
</span><a href="Control.Monad.Trans.State.Strict.html#runStateT"><span class="hs-identifier hs-var hs-var">runStateT</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621679082027"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679082026"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679082025"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621679082027"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-159"></span><span>
</span><span id="line-160"></span><span class="hs-comment">-- | Evaluate a state computation with the given initial state</span><span>
</span><span id="line-161"></span><span class="hs-comment">-- and return the final value, discarding the final state.</span><span>
</span><span id="line-162"></span><span class="hs-comment">--</span><span>
</span><span id="line-163"></span><span class="hs-comment">-- * @'evalStateT' m s = 'liftM' 'fst' ('runStateT' m s)@</span><span>
</span><span id="line-164"></span><span id="local-6989586621679081976"><span id="local-6989586621679081977"><span id="local-6989586621679081978"><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#evalStateT"><span class="hs-identifier hs-type">evalStateT</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081978"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081977"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081978"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081976"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679081977"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679081978"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081976"><span class="hs-identifier hs-type">a</span></a></span></span></span></span><span>
</span><span id="line-165"></span><span id="evalStateT"><span class="annot"><span class="annottext">evalStateT :: forall (m :: * -&gt; *) s a. Monad m =&gt; StateT s m a -&gt; s -&gt; m a
</span><a href="Control.Monad.Trans.State.Strict.html#evalStateT"><span class="hs-identifier hs-var hs-var">evalStateT</span></a></span></span><span> </span><span id="local-6989586621679081740"><span class="annot"><span class="annottext">StateT s m a
</span><a href="#local-6989586621679081740"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621679081739"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081739"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-166"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621679081738"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679081738"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">s
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">StateT s m a -&gt; s -&gt; m (a, s)
forall s (m :: * -&gt; *) a. StateT s m a -&gt; s -&gt; m (a, s)
</span><a href="Control.Monad.Trans.State.Strict.html#runStateT"><span class="hs-identifier hs-var hs-var">runStateT</span></a></span><span> </span><span class="annot"><span class="annottext">StateT s m a
</span><a href="#local-6989586621679081740"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081739"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-167"></span><span>    </span><span class="annot"><span class="annottext">a -&gt; m a
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679081738"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-168"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#evalStateT"><span class="hs-pragma hs-type">evalStateT</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-169"></span><span>
</span><span id="line-170"></span><span class="hs-comment">-- | Evaluate a state computation with the given initial state</span><span>
</span><span id="line-171"></span><span class="hs-comment">-- and return the final state, discarding the final value.</span><span>
</span><span id="line-172"></span><span class="hs-comment">--</span><span>
</span><span id="line-173"></span><span class="hs-comment">-- * @'execStateT' m s = 'liftM' 'snd' ('runStateT' m s)@</span><span>
</span><span id="line-174"></span><span id="local-6989586621679081970"><span id="local-6989586621679081971"><span id="local-6989586621679081972"><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#execStateT"><span class="hs-identifier hs-type">execStateT</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081972"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081971"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081972"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081970"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679081971"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679081972"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081971"><span class="hs-identifier hs-type">s</span></a></span></span></span></span><span>
</span><span id="line-175"></span><span id="execStateT"><span class="annot"><span class="annottext">execStateT :: forall (m :: * -&gt; *) s a. Monad m =&gt; StateT s m a -&gt; s -&gt; m s
</span><a href="Control.Monad.Trans.State.Strict.html#execStateT"><span class="hs-identifier hs-var hs-var">execStateT</span></a></span></span><span> </span><span id="local-6989586621679081734"><span class="annot"><span class="annottext">StateT s m a
</span><a href="#local-6989586621679081734"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621679081733"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081733"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-176"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679081732"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081732"><span class="hs-identifier hs-var">s'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">StateT s m a -&gt; s -&gt; m (a, s)
forall s (m :: * -&gt; *) a. StateT s m a -&gt; s -&gt; m (a, s)
</span><a href="Control.Monad.Trans.State.Strict.html#runStateT"><span class="hs-identifier hs-var hs-var">runStateT</span></a></span><span> </span><span class="annot"><span class="annottext">StateT s m a
</span><a href="#local-6989586621679081734"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081733"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-177"></span><span>    </span><span class="annot"><span class="annottext">s -&gt; m s
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081732"><span class="hs-identifier hs-var">s'</span></a></span><span>
</span><span id="line-178"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#execStateT"><span class="hs-pragma hs-type">execStateT</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-179"></span><span>
</span><span id="line-180"></span><span class="hs-comment">-- | Map both the return value and final state of a computation using</span><span>
</span><span id="line-181"></span><span class="hs-comment">-- the given function.</span><span>
</span><span id="line-182"></span><span class="hs-comment">--</span><span>
</span><span id="line-183"></span><span class="hs-comment">-- * @'runStateT' ('mapStateT' f m) = f . 'runStateT' m@</span><span>
</span><span id="line-184"></span><span id="local-6989586621679081990"><span id="local-6989586621679081991"><span id="local-6989586621679081992"><span id="local-6989586621679081993"><span id="local-6989586621679081994"><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#mapStateT"><span class="hs-identifier hs-type">mapStateT</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679081994"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679081993"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621679081992"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679081991"><span class="hs-identifier hs-type">n</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679081990"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621679081992"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081992"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081994"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081993"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081992"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081991"><span class="hs-identifier hs-type">n</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081990"><span class="hs-identifier hs-type">b</span></a></span></span></span></span></span></span><span>
</span><span id="line-185"></span><span id="mapStateT"><span class="annot"><span class="annottext">mapStateT :: forall (m :: * -&gt; *) a s (n :: * -&gt; *) b.
(m (a, s) -&gt; n (b, s)) -&gt; StateT s m a -&gt; StateT s n b
</span><a href="Control.Monad.Trans.State.Strict.html#mapStateT"><span class="hs-identifier hs-var hs-var">mapStateT</span></a></span></span><span> </span><span id="local-6989586621679081731"><span class="annot"><span class="annottext">m (a, s) -&gt; n (b, s)
</span><a href="#local-6989586621679081731"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621679081730"><span class="annot"><span class="annottext">StateT s m a
</span><a href="#local-6989586621679081730"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(s -&gt; n (b, s)) -&gt; StateT s n b
forall s (m :: * -&gt; *) a. (s -&gt; m (a, s)) -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-var">StateT</span></a></span><span> </span><span class="annot"><span class="annottext">((s -&gt; n (b, s)) -&gt; StateT s n b)
-&gt; (s -&gt; n (b, s)) -&gt; StateT s n b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">m (a, s) -&gt; n (b, s)
</span><a href="#local-6989586621679081731"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">(m (a, s) -&gt; n (b, s)) -&gt; (s -&gt; m (a, s)) -&gt; s -&gt; n (b, s)
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">StateT s m a -&gt; s -&gt; m (a, s)
forall s (m :: * -&gt; *) a. StateT s m a -&gt; s -&gt; m (a, s)
</span><a href="Control.Monad.Trans.State.Strict.html#runStateT"><span class="hs-identifier hs-var hs-var">runStateT</span></a></span><span> </span><span class="annot"><span class="annottext">StateT s m a
</span><a href="#local-6989586621679081730"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-186"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#mapStateT"><span class="hs-pragma hs-type">mapStateT</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-187"></span><span>
</span><span id="line-188"></span><span class="hs-comment">-- | @'withStateT' f m@ executes action @m@ on a state modified by</span><span>
</span><span id="line-189"></span><span class="hs-comment">-- applying @f@.</span><span>
</span><span id="line-190"></span><span class="hs-comment">--</span><span>
</span><span id="line-191"></span><span class="hs-comment">-- * @'withStateT' f m = 'modify' f &gt;&gt; m@</span><span>
</span><span id="line-192"></span><span id="local-6989586621679081982"><span id="local-6989586621679081983"><span id="local-6989586621679081984"><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#withStateT"><span class="hs-identifier hs-type">withStateT</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679081984"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679081984"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081984"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081983"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081982"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081984"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081983"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081982"><span class="hs-identifier hs-type">a</span></a></span></span></span></span><span>
</span><span id="line-193"></span><span id="withStateT"><span class="annot"><span class="annottext">withStateT :: forall s (m :: * -&gt; *) a. (s -&gt; s) -&gt; StateT s m a -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#withStateT"><span class="hs-identifier hs-var hs-var">withStateT</span></a></span></span><span> </span><span id="local-6989586621679081729"><span class="annot"><span class="annottext">s -&gt; s
</span><a href="#local-6989586621679081729"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621679081728"><span class="annot"><span class="annottext">StateT s m a
</span><a href="#local-6989586621679081728"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(s -&gt; m (a, s)) -&gt; StateT s m a
forall s (m :: * -&gt; *) a. (s -&gt; m (a, s)) -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-var">StateT</span></a></span><span> </span><span class="annot"><span class="annottext">((s -&gt; m (a, s)) -&gt; StateT s m a)
-&gt; (s -&gt; m (a, s)) -&gt; StateT s m a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">StateT s m a -&gt; s -&gt; m (a, s)
forall s (m :: * -&gt; *) a. StateT s m a -&gt; s -&gt; m (a, s)
</span><a href="Control.Monad.Trans.State.Strict.html#runStateT"><span class="hs-identifier hs-var hs-var">runStateT</span></a></span><span> </span><span class="annot"><span class="annottext">StateT s m a
</span><a href="#local-6989586621679081728"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">(s -&gt; m (a, s)) -&gt; (s -&gt; s) -&gt; s -&gt; m (a, s)
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">s -&gt; s
</span><a href="#local-6989586621679081729"><span class="hs-identifier hs-var">f</span></a></span><span>
</span><span id="line-194"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#withStateT"><span class="hs-pragma hs-type">withStateT</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-195"></span><span>
</span><span id="line-196"></span><span id="local-6989586621679081949"><span id="local-6989586621679081950"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679081725"><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#Functor"><span class="hs-identifier hs-type">Functor</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081950"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Functor"><span class="hs-identifier hs-type">Functor</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081949"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081950"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-197"></span><span>    </span><span id="local-6989586621679081722"><span class="annot"><span class="annottext">fmap :: forall a b. (a -&gt; b) -&gt; StateT s m a -&gt; StateT s m b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var hs-var hs-var hs-var">fmap</span></a></span></span><span> </span><span id="local-6989586621679081721"><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621679081721"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621679081720"><span class="annot"><span class="annottext">StateT s m a
</span><a href="#local-6989586621679081720"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(s -&gt; m (b, s)) -&gt; StateT s m b
forall s (m :: * -&gt; *) a. (s -&gt; m (a, s)) -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-var">StateT</span></a></span><span> </span><span class="annot"><span class="annottext">((s -&gt; m (b, s)) -&gt; StateT s m b)
-&gt; (s -&gt; m (b, s)) -&gt; StateT s m b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679081719"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081719"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-198"></span><span>        </span><span class="annot"><span class="annottext">((a, s) -&gt; (b, s)) -&gt; m (a, s) -&gt; m (b, s)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679081718"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679081718"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679081717"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081717"><span class="hs-identifier hs-var">s'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621679081721"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679081718"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081717"><span class="hs-identifier hs-var">s'</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(m (a, s) -&gt; m (b, s)) -&gt; m (a, s) -&gt; m (b, s)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">StateT s m a -&gt; s -&gt; m (a, s)
forall s (m :: * -&gt; *) a. StateT s m a -&gt; s -&gt; m (a, s)
</span><a href="Control.Monad.Trans.State.Strict.html#runStateT"><span class="hs-identifier hs-var hs-var">runStateT</span></a></span><span> </span><span class="annot"><span class="annottext">StateT s m a
</span><a href="#local-6989586621679081720"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081719"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-199"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-pragma hs-type">fmap</span></a></span><span> </span><span class="hs-pragma">#-}</span></span></span><span>
</span><span id="line-200"></span><span>
</span><span id="line-201"></span><span id="local-6989586621679081934"><span id="local-6989586621679081935"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679081708"><span id="local-6989586621679081711"><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#Functor"><span class="hs-identifier hs-type">Functor</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081935"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081935"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Applicative"><span class="hs-identifier hs-type">Applicative</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081934"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081935"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-202"></span><span>    </span><span id="local-6989586621679081705"><span class="annot"><span class="annottext">pure :: forall a. a -&gt; StateT s m a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var hs-var hs-var hs-var">pure</span></a></span></span><span> </span><span id="local-6989586621679081704"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679081704"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(s -&gt; m (a, s)) -&gt; StateT s m a
forall s (m :: * -&gt; *) a. (s -&gt; m (a, s)) -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-var">StateT</span></a></span><span> </span><span class="annot"><span class="annottext">((s -&gt; m (a, s)) -&gt; StateT s m a)
-&gt; (s -&gt; m (a, s)) -&gt; StateT s m a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679081703"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081703"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(a, s) -&gt; m (a, s)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679081704"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081703"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-203"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#pure"><span class="hs-pragma hs-type">pure</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-204"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span id="local-6989586621679081699"><span class="annot"><span class="annottext">s -&gt; m (a -&gt; b, s)
</span><a href="#local-6989586621679081699"><span class="hs-identifier hs-var">mf</span></a></span></span><span> </span><span id="local-6989586621679081698"><span class="annot"><span class="annottext">&lt;*&gt; :: forall a b. StateT s m (a -&gt; b) -&gt; StateT s m a -&gt; StateT s m b
</span><a href="../../base/src/GHC.Base.html#%3C%2A%3E"><span class="hs-operator hs-var hs-var hs-var hs-var">&lt;*&gt;</span></a></span></span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span id="local-6989586621679081697"><span class="annot"><span class="annottext">s -&gt; m (a, s)
</span><a href="#local-6989586621679081697"><span class="hs-identifier hs-var">mx</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(s -&gt; m (b, s)) -&gt; StateT s m b
forall s (m :: * -&gt; *) a. (s -&gt; m (a, s)) -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-var">StateT</span></a></span><span> </span><span class="annot"><span class="annottext">((s -&gt; m (b, s)) -&gt; StateT s m b)
-&gt; (s -&gt; m (b, s)) -&gt; StateT s m b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679081696"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081696"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-205"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621679081695"><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621679081695"><span class="hs-identifier hs-var">f</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679081694"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081694"><span class="hs-identifier hs-var">s'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">s -&gt; m (a -&gt; b, s)
</span><a href="#local-6989586621679081699"><span class="hs-identifier hs-var">mf</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081696"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-206"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621679081693"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679081693"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679081692"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081692"><span class="hs-identifier hs-var">s''</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">s -&gt; m (a, s)
</span><a href="#local-6989586621679081697"><span class="hs-identifier hs-var">mx</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081694"><span class="hs-identifier hs-var">s'</span></a></span><span>
</span><span id="line-207"></span><span>        </span><span class="annot"><span class="annottext">(b, s) -&gt; m (b, s)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621679081695"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679081693"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081692"><span class="hs-identifier hs-var">s''</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-208"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="hs-pragma">(</span><span class="hs-pragma">&lt;*&gt;</span><span class="hs-pragma">)</span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-209"></span><span>    </span><span id="local-6989586621679081690"><span class="annot"><span class="annottext">StateT s m a
</span><a href="#local-6989586621679081690"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621679081689"><span class="annot"><span class="annottext">*&gt; :: forall a b. StateT s m a -&gt; StateT s m b -&gt; StateT s m b
</span><a href="../../base/src/GHC.Base.html#%2A%3E"><span class="hs-operator hs-var hs-var hs-var hs-var">*&gt;</span></a></span></span><span> </span><span id="local-6989586621679081688"><span class="annot"><span class="annottext">StateT s m b
</span><a href="#local-6989586621679081688"><span class="hs-identifier hs-var">k</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StateT s m a
</span><a href="#local-6989586621679081690"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">StateT s m a -&gt; (a -&gt; StateT s m b) -&gt; StateT s m b
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">a
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">StateT s m b
</span><a href="#local-6989586621679081688"><span class="hs-identifier hs-var">k</span></a></span><span>
</span><span id="line-210"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="hs-pragma">(</span><span class="hs-pragma">*&gt;</span><span class="hs-pragma">)</span><span> </span><span class="hs-pragma">#-}</span></span></span><span>
</span><span id="line-211"></span><span>
</span><span id="line-212"></span><span id="local-6989586621679081918"><span id="local-6989586621679081919"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679081680"><span id="local-6989586621679081682"><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#Functor"><span class="hs-identifier hs-type">Functor</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081919"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#MonadPlus"><span class="hs-identifier hs-type">MonadPlus</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081919"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Alternative"><span class="hs-identifier hs-type">Alternative</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081918"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081919"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-213"></span><span>    </span><span id="local-6989586621679081677"><span class="annot"><span class="annottext">empty :: forall a. StateT s m a
</span><a href="../../base/src/GHC.Base.html#empty"><span class="hs-identifier hs-var hs-var hs-var hs-var">empty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(s -&gt; m (a, s)) -&gt; StateT s m a
forall s (m :: * -&gt; *) a. (s -&gt; m (a, s)) -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-var">StateT</span></a></span><span> </span><span class="annot"><span class="annottext">((s -&gt; m (a, s)) -&gt; StateT s m a)
-&gt; (s -&gt; m (a, s)) -&gt; StateT s m a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span class="annot"><span class="annottext">s
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">m (a, s)
forall (m :: * -&gt; *) a. MonadPlus m =&gt; m a
</span><a href="../../base/src/GHC.Base.html#mzero"><span class="hs-identifier hs-var">mzero</span></a></span><span>
</span><span id="line-214"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#empty"><span class="hs-pragma hs-type">empty</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-215"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span id="local-6989586621679081673"><span class="annot"><span class="annottext">s -&gt; m (a, s)
</span><a href="#local-6989586621679081673"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621679081672"><span class="annot"><span class="annottext">&lt;|&gt; :: forall a. StateT s m a -&gt; StateT s m a -&gt; StateT s m a
</span><a href="../../base/src/GHC.Base.html#%3C%7C%3E"><span class="hs-operator hs-var hs-var hs-var hs-var">&lt;|&gt;</span></a></span></span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span id="local-6989586621679081670"><span class="annot"><span class="annottext">s -&gt; m (a, s)
</span><a href="#local-6989586621679081670"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(s -&gt; m (a, s)) -&gt; StateT s m a
forall s (m :: * -&gt; *) a. (s -&gt; m (a, s)) -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-var">StateT</span></a></span><span> </span><span class="annot"><span class="annottext">((s -&gt; m (a, s)) -&gt; StateT s m a)
-&gt; (s -&gt; m (a, s)) -&gt; StateT s m a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679081669"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081669"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">s -&gt; m (a, s)
</span><a href="#local-6989586621679081673"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081669"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="annot"><span class="annottext">m (a, s) -&gt; m (a, s) -&gt; m (a, s)
forall (m :: * -&gt; *) a. MonadPlus m =&gt; m a -&gt; m a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#mplus"><span class="hs-operator hs-var">`mplus`</span></a></span><span> </span><span class="annot"><span class="annottext">s -&gt; m (a, s)
</span><a href="#local-6989586621679081670"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081669"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-216"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="hs-pragma">(</span><span class="hs-pragma">&lt;|&gt;</span><span class="hs-pragma">)</span><span> </span><span class="hs-pragma">#-}</span></span></span><span>
</span><span id="line-217"></span><span>
</span><span id="line-218"></span><span id="local-6989586621679081929"><span id="local-6989586621679081930"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679081661"><span id="local-6989586621679081663"><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081930"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081929"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081930"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span></span></span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">
#if !(MIN_VERSION_base(4,8,0))
</span><span>    </span><span class="hs-identifier">return</span><span> </span><span class="hs-identifier">a</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">StateT</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">s</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">return</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">a</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">s</span><span class="hs-special">)</span><span>
</span><span id="line-221"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="hs-pragma">return</span><span> </span><span class="hs-pragma">#-}</span><span class="hs-cpp">
#endif
</span><span>    </span><span id="local-6989586621679081658"><span class="annot"><span class="annottext">StateT s m a
</span><a href="#local-6989586621679081658"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621679081657"><span class="annot"><span class="annottext">&gt;&gt;= :: forall a b. StateT s m a -&gt; (a -&gt; StateT s m b) -&gt; StateT s m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var hs-var hs-var hs-var">&gt;&gt;=</span></a></span></span><span> </span><span id="local-6989586621679081656"><span class="annot"><span class="annottext">a -&gt; StateT s m b
</span><a href="#local-6989586621679081656"><span class="hs-identifier hs-var">k</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(s -&gt; m (b, s)) -&gt; StateT s m b
forall s (m :: * -&gt; *) a. (s -&gt; m (a, s)) -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-var">StateT</span></a></span><span> </span><span class="annot"><span class="annottext">((s -&gt; m (b, s)) -&gt; StateT s m b)
-&gt; (s -&gt; m (b, s)) -&gt; StateT s m b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679081655"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081655"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-224"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621679081654"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679081654"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679081653"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081653"><span class="hs-identifier hs-var">s'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">StateT s m a -&gt; s -&gt; m (a, s)
forall s (m :: * -&gt; *) a. StateT s m a -&gt; s -&gt; m (a, s)
</span><a href="Control.Monad.Trans.State.Strict.html#runStateT"><span class="hs-identifier hs-var hs-var">runStateT</span></a></span><span> </span><span class="annot"><span class="annottext">StateT s m a
</span><a href="#local-6989586621679081658"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081655"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-225"></span><span>        </span><span class="annot"><span class="annottext">StateT s m b -&gt; s -&gt; m (b, s)
forall s (m :: * -&gt; *) a. StateT s m a -&gt; s -&gt; m (a, s)
</span><a href="Control.Monad.Trans.State.Strict.html#runStateT"><span class="hs-identifier hs-var hs-var">runStateT</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; StateT s m b
</span><a href="#local-6989586621679081656"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679081654"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081653"><span class="hs-identifier hs-var">s'</span></a></span><span>
</span><span id="line-226"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="hs-pragma">(</span><span class="hs-pragma">&gt;&gt;=</span><span class="hs-pragma">)</span><span> </span><span class="hs-pragma">#-}</span></span></span><span class="hs-cpp">
#if !(MIN_VERSION_base(4,13,0))
</span><span>    </span><span class="hs-identifier">fail</span><span> </span><span class="hs-identifier">str</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">StateT</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">fail</span><span> </span><span class="hs-identifier">str</span><span>
</span><span id="line-229"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="hs-pragma">fail</span><span> </span><span class="hs-pragma">#-}</span><span class="hs-cpp">
#endif
</span><span class="hs-cpp">
#if MIN_VERSION_base(4,9,0)
</span><span id="local-6989586621679081904"><span id="local-6989586621679081905"><span class="hs-keyword">instance</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Control.Monad.Fail.html#MonadFail"><span class="hs-identifier hs-type">Fail.MonadFail</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081905"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.Fail.html#MonadFail"><span class="hs-identifier hs-type">Fail.MonadFail</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081904"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081905"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-234"></span><span>    </span><span id="local-6989586621679081643"><span class="annot"><span class="annottext">fail :: forall a. String -&gt; StateT s m a
</span><a href="../../base/src/Control.Monad.Fail.html#fail"><span class="hs-identifier hs-var hs-var hs-var hs-var">fail</span></a></span></span><span> </span><span id="local-6989586621679081642"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679081642"><span class="hs-identifier hs-var">str</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(s -&gt; m (a, s)) -&gt; StateT s m a
forall s (m :: * -&gt; *) a. (s -&gt; m (a, s)) -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-var">StateT</span></a></span><span> </span><span class="annot"><span class="annottext">((s -&gt; m (a, s)) -&gt; StateT s m a)
-&gt; (s -&gt; m (a, s)) -&gt; StateT s m a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span class="annot"><span class="annottext">s
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; m (a, s)
forall (m :: * -&gt; *) a. MonadFail m =&gt; String -&gt; m a
</span><a href="../../base/src/Control.Monad.Fail.html#fail"><span class="hs-identifier hs-var">Fail.fail</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679081642"><span class="hs-identifier hs-var">str</span></a></span><span>
</span><span id="line-235"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.Fail.html#fail"><span class="hs-pragma hs-type">fail</span></a></span><span> </span><span class="hs-pragma">#-}</span></span></span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-238"></span><span id="local-6989586621679081899"><span id="local-6989586621679081900"><span class="hs-keyword">instance</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#MonadPlus"><span class="hs-identifier hs-type">MonadPlus</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081900"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#MonadPlus"><span class="hs-identifier hs-type">MonadPlus</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081899"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081900"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-239"></span><span>    </span><span id="local-6989586621679081625"><span class="annot"><span class="annottext">mzero :: forall a. StateT s m a
</span><a href="#local-6989586621679081625"><span class="hs-identifier hs-var hs-var hs-var hs-var">mzero</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(s -&gt; m (a, s)) -&gt; StateT s m a
forall s (m :: * -&gt; *) a. (s -&gt; m (a, s)) -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-var">StateT</span></a></span><span> </span><span class="annot"><span class="annottext">((s -&gt; m (a, s)) -&gt; StateT s m a)
-&gt; (s -&gt; m (a, s)) -&gt; StateT s m a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span class="annot"><span class="annottext">s
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">m (a, s)
forall (m :: * -&gt; *) a. MonadPlus m =&gt; m a
</span><a href="../../base/src/GHC.Base.html#mzero"><span class="hs-identifier hs-var">mzero</span></a></span><span>
</span><span id="line-240"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#mzero"><span class="hs-pragma hs-type">mzero</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-241"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span id="local-6989586621679081623"><span class="annot"><span class="annottext">s -&gt; m (a, s)
</span><a href="#local-6989586621679081623"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621679081622"><span class="annot"><span class="annottext">mplus :: forall a. StateT s m a -&gt; StateT s m a -&gt; StateT s m a
</span><a href="#local-6989586621679081622"><span class="hs-operator hs-var hs-var hs-var hs-var">`mplus`</span></a></span></span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span id="local-6989586621679081621"><span class="annot"><span class="annottext">s -&gt; m (a, s)
</span><a href="#local-6989586621679081621"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(s -&gt; m (a, s)) -&gt; StateT s m a
forall s (m :: * -&gt; *) a. (s -&gt; m (a, s)) -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-var">StateT</span></a></span><span> </span><span class="annot"><span class="annottext">((s -&gt; m (a, s)) -&gt; StateT s m a)
-&gt; (s -&gt; m (a, s)) -&gt; StateT s m a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679081620"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081620"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">s -&gt; m (a, s)
</span><a href="#local-6989586621679081623"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081620"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="annot"><span class="annottext">m (a, s) -&gt; m (a, s) -&gt; m (a, s)
forall (m :: * -&gt; *) a. MonadPlus m =&gt; m a -&gt; m a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#mplus"><span class="hs-operator hs-var">`mplus`</span></a></span><span> </span><span class="annot"><span class="annottext">s -&gt; m (a, s)
</span><a href="#local-6989586621679081621"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081620"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-242"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#mplus"><span class="hs-pragma hs-type">mplus</span></a></span><span> </span><span class="hs-pragma">#-}</span></span></span><span>
</span><span id="line-243"></span><span>
</span><span id="line-244"></span><span id="local-6989586621679081891"><span id="local-6989586621679081892"><span class="hs-keyword">instance</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Control.Monad.Fix.html#MonadFix"><span class="hs-identifier hs-type">MonadFix</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081892"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.Fix.html#MonadFix"><span class="hs-identifier hs-type">MonadFix</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081891"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081892"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-245"></span><span>    </span><span id="local-6989586621679081610"><span class="annot"><span class="annottext">mfix :: forall a. (a -&gt; StateT s m a) -&gt; StateT s m a
</span><a href="../../base/src/Control.Monad.Fix.html#mfix"><span class="hs-identifier hs-var hs-var hs-var hs-var">mfix</span></a></span></span><span> </span><span id="local-6989586621679081609"><span class="annot"><span class="annottext">a -&gt; StateT s m a
</span><a href="#local-6989586621679081609"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(s -&gt; m (a, s)) -&gt; StateT s m a
forall s (m :: * -&gt; *) a. (s -&gt; m (a, s)) -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-var">StateT</span></a></span><span> </span><span class="annot"><span class="annottext">((s -&gt; m (a, s)) -&gt; StateT s m a)
-&gt; (s -&gt; m (a, s)) -&gt; StateT s m a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679081608"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081608"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">((a, s) -&gt; m (a, s)) -&gt; m (a, s)
forall (m :: * -&gt; *) a. MonadFix m =&gt; (a -&gt; m a) -&gt; m a
</span><a href="../../base/src/Control.Monad.Fix.html#mfix"><span class="hs-identifier hs-var">mfix</span></a></span><span> </span><span class="annot"><span class="annottext">(((a, s) -&gt; m (a, s)) -&gt; m (a, s))
-&gt; ((a, s) -&gt; m (a, s)) -&gt; m (a, s)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-glyph">~</span><span class="hs-special">(</span><span id="local-6989586621679081607"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679081607"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">s
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">StateT s m a -&gt; s -&gt; m (a, s)
forall s (m :: * -&gt; *) a. StateT s m a -&gt; s -&gt; m (a, s)
</span><a href="Control.Monad.Trans.State.Strict.html#runStateT"><span class="hs-identifier hs-var hs-var">runStateT</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; StateT s m a
</span><a href="#local-6989586621679081609"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679081607"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081608"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-246"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.Fix.html#mfix"><span class="hs-pragma hs-type">mfix</span></a></span><span> </span><span class="hs-pragma">#-}</span></span></span><span>
</span><span id="line-247"></span><span>
</span><span id="line-248"></span><span id="local-6989586621679081884"><span class="hs-keyword">instance</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Class.html#MonadTrans"><span class="hs-identifier hs-type">MonadTrans</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081884"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-249"></span><span>    </span><span id="local-6989586621679081600"><span class="annot"><span class="annottext">lift :: forall (m :: * -&gt; *) a. Monad m =&gt; m a -&gt; StateT s m a
</span><a href="Control.Monad.Trans.Class.html#lift"><span class="hs-identifier hs-var hs-var hs-var hs-var">lift</span></a></span></span><span> </span><span id="local-6989586621679081598"><span class="annot"><span class="annottext">m a
</span><a href="#local-6989586621679081598"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(s -&gt; m (a, s)) -&gt; StateT s m a
forall s (m :: * -&gt; *) a. (s -&gt; m (a, s)) -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-var">StateT</span></a></span><span> </span><span class="annot"><span class="annottext">((s -&gt; m (a, s)) -&gt; StateT s m a)
-&gt; (s -&gt; m (a, s)) -&gt; StateT s m a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679081597"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081597"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-250"></span><span>        </span><span id="local-6989586621679081596"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679081596"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">m a
</span><a href="#local-6989586621679081598"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-251"></span><span>        </span><span class="annot"><span class="annottext">(a, s) -&gt; m (a, s)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679081596"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081597"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-252"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Class.html#lift"><span class="hs-pragma hs-type">lift</span></a></span><span> </span><span class="hs-pragma">#-}</span></span><span>
</span><span id="line-253"></span><span>
</span><span id="line-254"></span><span id="local-6989586621679081875"><span id="local-6989586621679081876"><span class="hs-keyword">instance</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Control.Monad.IO.Class.html#MonadIO"><span class="hs-identifier hs-type">MonadIO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081876"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.IO.Class.html#MonadIO"><span class="hs-identifier hs-type">MonadIO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081875"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081876"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-255"></span><span>    </span><span id="local-6989586621679081584"><span class="annot"><span class="annottext">liftIO :: forall a. IO a -&gt; StateT s m a
</span><a href="../../base/src/Control.Monad.IO.Class.html#liftIO"><span class="hs-identifier hs-var hs-var hs-var hs-var">liftIO</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">m a -&gt; StateT s m a
forall (t :: (* -&gt; *) -&gt; * -&gt; *) (m :: * -&gt; *) a.
(MonadTrans t, Monad m) =&gt;
m a -&gt; t m a
</span><a href="Control.Monad.Trans.Class.html#lift"><span class="hs-identifier hs-var">lift</span></a></span><span> </span><span class="annot"><span class="annottext">(m a -&gt; StateT s m a) -&gt; (IO a -&gt; m a) -&gt; IO a -&gt; StateT s m a
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">IO a -&gt; m a
forall (m :: * -&gt; *) a. MonadIO m =&gt; IO a -&gt; m a
</span><a href="../../base/src/Control.Monad.IO.Class.html#liftIO"><span class="hs-identifier hs-var">liftIO</span></a></span><span>
</span><span id="line-256"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.IO.Class.html#liftIO"><span class="hs-pragma hs-type">liftIO</span></a></span><span> </span><span class="hs-pragma">#-}</span></span></span><span class="hs-cpp">

#if MIN_VERSION_base(4,12,0)
</span><span id="local-6989586621679081867"><span id="local-6989586621679081868"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679081580"><span class="annot"><a href="../../base/src/Data.Functor.Contravariant.html#Contravariant"><span class="hs-identifier hs-type">Contravariant</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081868"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../base/src/Data.Functor.Contravariant.html#Contravariant"><span class="hs-identifier hs-type">Contravariant</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081867"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081868"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-260"></span><span>    </span><span id="local-6989586621679081577"><span class="annot"><span class="annottext">contramap :: forall a' a. (a' -&gt; a) -&gt; StateT s m a -&gt; StateT s m a'
</span><a href="../../base/src/Data.Functor.Contravariant.html#contramap"><span class="hs-identifier hs-var hs-var hs-var hs-var">contramap</span></a></span></span><span> </span><span id="local-6989586621679081575"><span class="annot"><span class="annottext">a' -&gt; a
</span><a href="#local-6989586621679081575"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621679081574"><span class="annot"><span class="annottext">StateT s m a
</span><a href="#local-6989586621679081574"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(s -&gt; m (a', s)) -&gt; StateT s m a'
forall s (m :: * -&gt; *) a. (s -&gt; m (a, s)) -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-var">StateT</span></a></span><span> </span><span class="annot"><span class="annottext">((s -&gt; m (a', s)) -&gt; StateT s m a')
-&gt; (s -&gt; m (a', s)) -&gt; StateT s m a'
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679081573"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081573"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-261"></span><span>      </span><span class="annot"><span class="annottext">((a', s) -&gt; (a, s)) -&gt; m (a, s) -&gt; m (a', s)
forall (f :: * -&gt; *) a' a.
Contravariant f =&gt;
(a' -&gt; a) -&gt; f a -&gt; f a'
</span><a href="../../base/src/Data.Functor.Contravariant.html#contramap"><span class="hs-identifier hs-var">contramap</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679081572"><span class="annot"><span class="annottext">a'
</span><a href="#local-6989586621679081572"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679081571"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081571"><span class="hs-identifier hs-var">s'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a' -&gt; a
</span><a href="#local-6989586621679081575"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">a'
</span><a href="#local-6989586621679081572"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081571"><span class="hs-identifier hs-var">s'</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(m (a, s) -&gt; m (a', s)) -&gt; m (a, s) -&gt; m (a', s)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">StateT s m a -&gt; s -&gt; m (a, s)
forall s (m :: * -&gt; *) a. StateT s m a -&gt; s -&gt; m (a, s)
</span><a href="Control.Monad.Trans.State.Strict.html#runStateT"><span class="hs-identifier hs-var hs-var">runStateT</span></a></span><span> </span><span class="annot"><span class="annottext">StateT s m a
</span><a href="#local-6989586621679081574"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081573"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-262"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="../../base/src/Data.Functor.Contravariant.html#contramap"><span class="hs-pragma hs-type">contramap</span></a></span><span> </span><span class="hs-pragma">#-}</span></span></span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-265"></span><span class="hs-comment">-- | Fetch the current value of the state within the monad.</span><span>
</span><span id="line-266"></span><span id="local-6989586621679081863"><span id="local-6989586621679081864"><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#get"><span class="hs-identifier hs-type">get</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081864"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081863"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081864"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081863"><span class="hs-identifier hs-type">s</span></a></span></span></span><span>
</span><span id="line-267"></span><span id="get"><span class="annot"><span class="annottext">get :: forall (m :: * -&gt; *) s. Monad m =&gt; StateT s m s
</span><a href="Control.Monad.Trans.State.Strict.html#get"><span class="hs-identifier hs-var hs-var">get</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(s -&gt; (s, s)) -&gt; StateT s m s
forall (m :: * -&gt; *) s a. Monad m =&gt; (s -&gt; (a, s)) -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#state"><span class="hs-identifier hs-var">state</span></a></span><span> </span><span class="annot"><span class="annottext">((s -&gt; (s, s)) -&gt; StateT s m s) -&gt; (s -&gt; (s, s)) -&gt; StateT s m s
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679081568"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081568"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081568"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081568"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-268"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#get"><span class="hs-pragma hs-type">get</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-269"></span><span>
</span><span id="line-270"></span><span class="hs-comment">-- | @'put' s@ sets the state within the monad to @s@.</span><span>
</span><span id="line-271"></span><span id="local-6989586621679081859"><span id="local-6989586621679081860"><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#put"><span class="hs-identifier hs-type">put</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081860"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679081859"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081859"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081860"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span></span><span>
</span><span id="line-272"></span><span id="put"><span class="annot"><span class="annottext">put :: forall (m :: * -&gt; *) s. Monad m =&gt; s -&gt; StateT s m ()
</span><a href="Control.Monad.Trans.State.Strict.html#put"><span class="hs-identifier hs-var hs-var">put</span></a></span></span><span> </span><span id="local-6989586621679081565"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081565"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(s -&gt; ((), s)) -&gt; StateT s m ()
forall (m :: * -&gt; *) s a. Monad m =&gt; (s -&gt; (a, s)) -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#state"><span class="hs-identifier hs-var">state</span></a></span><span> </span><span class="annot"><span class="annottext">((s -&gt; ((), s)) -&gt; StateT s m ())
-&gt; (s -&gt; ((), s)) -&gt; StateT s m ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span class="annot"><span class="annottext">s
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081565"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-273"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#put"><span class="hs-pragma hs-type">put</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-274"></span><span>
</span><span id="line-275"></span><span class="hs-comment">-- | @'modify' f@ is an action that updates the state to the result of</span><span>
</span><span id="line-276"></span><span class="hs-comment">-- applying @f@ to the current state.</span><span>
</span><span id="line-277"></span><span class="hs-comment">--</span><span>
</span><span id="line-278"></span><span class="hs-comment">-- * @'modify' f = 'get' &gt;&gt;= ('put' . f)@</span><span>
</span><span id="line-279"></span><span id="local-6989586621679081855"><span id="local-6989586621679081856"><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#modify"><span class="hs-identifier hs-type">modify</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081856"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679081855"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679081855"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081855"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081856"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span></span><span>
</span><span id="line-280"></span><span id="modify"><span class="annot"><span class="annottext">modify :: forall (m :: * -&gt; *) s. Monad m =&gt; (s -&gt; s) -&gt; StateT s m ()
</span><a href="Control.Monad.Trans.State.Strict.html#modify"><span class="hs-identifier hs-var hs-var">modify</span></a></span></span><span> </span><span id="local-6989586621679081562"><span class="annot"><span class="annottext">s -&gt; s
</span><a href="#local-6989586621679081562"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(s -&gt; ((), s)) -&gt; StateT s m ()
forall (m :: * -&gt; *) s a. Monad m =&gt; (s -&gt; (a, s)) -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#state"><span class="hs-identifier hs-var">state</span></a></span><span> </span><span class="annot"><span class="annottext">((s -&gt; ((), s)) -&gt; StateT s m ())
-&gt; (s -&gt; ((), s)) -&gt; StateT s m ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679081561"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081561"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">s -&gt; s
</span><a href="#local-6989586621679081562"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081561"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-281"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#modify"><span class="hs-pragma hs-type">modify</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-282"></span><span>
</span><span id="line-283"></span><span class="hs-comment">-- | A variant of 'modify' in which the computation is strict in the</span><span>
</span><span id="line-284"></span><span class="hs-comment">-- new state.</span><span>
</span><span id="line-285"></span><span class="hs-comment">--</span><span>
</span><span id="line-286"></span><span class="hs-comment">-- * @'modify'' f = 'get' &gt;&gt;= (('$!') 'put' . f)@</span><span>
</span><span id="line-287"></span><span id="local-6989586621679081559"><span id="local-6989586621679081560"><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#modify%27"><span class="hs-identifier hs-type">modify'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081560"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679081559"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679081559"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081559"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081560"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span></span><span>
</span><span id="line-288"></span><span id="modify%27"><span class="annot"><span class="annottext">modify' :: forall (m :: * -&gt; *) s. Monad m =&gt; (s -&gt; s) -&gt; StateT s m ()
</span><a href="Control.Monad.Trans.State.Strict.html#modify%27"><span class="hs-identifier hs-var hs-var">modify'</span></a></span></span><span> </span><span id="local-6989586621679081554"><span class="annot"><span class="annottext">s -&gt; s
</span><a href="#local-6989586621679081554"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-289"></span><span>    </span><span id="local-6989586621679081553"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081553"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">StateT s m s
forall (m :: * -&gt; *) s. Monad m =&gt; StateT s m s
</span><a href="Control.Monad.Trans.State.Strict.html#get"><span class="hs-identifier hs-var">get</span></a></span><span>
</span><span id="line-290"></span><span>    </span><span class="annot"><span class="annottext">s -&gt; StateT s m ()
forall (m :: * -&gt; *) s. Monad m =&gt; s -&gt; StateT s m ()
</span><a href="Control.Monad.Trans.State.Strict.html#put"><span class="hs-identifier hs-var">put</span></a></span><span> </span><span class="annot"><span class="annottext">(s -&gt; StateT s m ()) -&gt; s -&gt; StateT s m ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">s -&gt; s
</span><a href="#local-6989586621679081554"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081553"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-291"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#modify%27"><span class="hs-pragma hs-type">modify'</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-292"></span><span>
</span><span id="line-293"></span><span class="hs-comment">-- | Get a specific component of the state, using a projection function</span><span>
</span><span id="line-294"></span><span class="hs-comment">-- supplied.</span><span>
</span><span id="line-295"></span><span class="hs-comment">--</span><span>
</span><span id="line-296"></span><span class="hs-comment">-- * @'gets' f = 'liftM' f 'get'@</span><span>
</span><span id="line-297"></span><span id="local-6989586621679081848"><span id="local-6989586621679081849"><span id="local-6989586621679081850"><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#gets"><span class="hs-identifier hs-type">gets</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081850"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679081849"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679081848"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081849"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081850"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081848"><span class="hs-identifier hs-type">a</span></a></span></span></span></span><span>
</span><span id="line-298"></span><span id="gets"><span class="annot"><span class="annottext">gets :: forall (m :: * -&gt; *) s a. Monad m =&gt; (s -&gt; a) -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#gets"><span class="hs-identifier hs-var hs-var">gets</span></a></span></span><span> </span><span id="local-6989586621679081549"><span class="annot"><span class="annottext">s -&gt; a
</span><a href="#local-6989586621679081549"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(s -&gt; (a, s)) -&gt; StateT s m a
forall (m :: * -&gt; *) s a. Monad m =&gt; (s -&gt; (a, s)) -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#state"><span class="hs-identifier hs-var">state</span></a></span><span> </span><span class="annot"><span class="annottext">((s -&gt; (a, s)) -&gt; StateT s m a) -&gt; (s -&gt; (a, s)) -&gt; StateT s m a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679081548"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081548"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">s -&gt; a
</span><a href="#local-6989586621679081549"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081548"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081548"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-299"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#gets"><span class="hs-pragma hs-type">gets</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-300"></span><span>
</span><span id="line-301"></span><span class="hs-comment">-- | Uniform lifting of a @callCC@ operation to the new monad.</span><span>
</span><span id="line-302"></span><span class="hs-comment">-- This version rolls back to the original state on entering the</span><span>
</span><span id="line-303"></span><span class="hs-comment">-- continuation.</span><span>
</span><span id="line-304"></span><span id="local-6989586621679081841"><span id="local-6989586621679081842"><span id="local-6989586621679081843"><span id="local-6989586621679081844"><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#liftCallCC"><span class="hs-identifier hs-type">liftCallCC</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Control.Monad.Signatures.html#CallCC"><span class="hs-identifier hs-type">CallCC</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081844"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679081843"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621679081842"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679081841"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621679081842"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Signatures.html#CallCC"><span class="hs-identifier hs-type">CallCC</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081842"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081844"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><a href="#local-6989586621679081843"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081841"><span class="hs-identifier hs-type">b</span></a></span></span></span></span></span><span>
</span><span id="line-305"></span><span id="liftCallCC"><span class="annot"><span class="annottext">liftCallCC :: forall (m :: * -&gt; *) a s b.
CallCC m (a, s) (b, s) -&gt; CallCC (StateT s m) a b
</span><a href="Control.Monad.Trans.State.Strict.html#liftCallCC"><span class="hs-identifier hs-var hs-var">liftCallCC</span></a></span></span><span> </span><span id="local-6989586621679081547"><span class="annot"><span class="annottext">CallCC m (a, s) (b, s)
</span><a href="#local-6989586621679081547"><span class="hs-identifier hs-var">callCC</span></a></span></span><span> </span><span id="local-6989586621679081546"><span class="annot"><span class="annottext">(a -&gt; StateT s m b) -&gt; StateT s m a
</span><a href="#local-6989586621679081546"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(s -&gt; m (a, s)) -&gt; StateT s m a
forall s (m :: * -&gt; *) a. (s -&gt; m (a, s)) -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-var">StateT</span></a></span><span> </span><span class="annot"><span class="annottext">((s -&gt; m (a, s)) -&gt; StateT s m a)
-&gt; (s -&gt; m (a, s)) -&gt; StateT s m a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679081545"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081545"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-306"></span><span>    </span><span class="annot"><span class="annottext">CallCC m (a, s) (b, s)
</span><a href="#local-6989586621679081547"><span class="hs-identifier hs-var">callCC</span></a></span><span> </span><span class="annot"><span class="annottext">CallCC m (a, s) (b, s) -&gt; CallCC m (a, s) (b, s)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679081544"><span class="annot"><span class="annottext">(a, s) -&gt; m (b, s)
</span><a href="#local-6989586621679081544"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-307"></span><span>    </span><span class="annot"><span class="annottext">StateT s m a -&gt; s -&gt; m (a, s)
forall s (m :: * -&gt; *) a. StateT s m a -&gt; s -&gt; m (a, s)
</span><a href="Control.Monad.Trans.State.Strict.html#runStateT"><span class="hs-identifier hs-var hs-var">runStateT</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(a -&gt; StateT s m b) -&gt; StateT s m a
</span><a href="#local-6989586621679081546"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679081543"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679081543"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(s -&gt; m (b, s)) -&gt; StateT s m b
forall s (m :: * -&gt; *) a. (s -&gt; m (a, s)) -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-var">StateT</span></a></span><span> </span><span class="annot"><span class="annottext">((s -&gt; m (b, s)) -&gt; StateT s m b)
-&gt; (s -&gt; m (b, s)) -&gt; StateT s m b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span class="annot"><span class="annottext">s
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(a, s) -&gt; m (b, s)
</span><a href="#local-6989586621679081544"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679081543"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081545"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081545"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-308"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#liftCallCC"><span class="hs-pragma hs-type">liftCallCC</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-309"></span><span>
</span><span id="line-310"></span><span class="hs-comment">-- | In-situ lifting of a @callCC@ operation to the new monad.</span><span>
</span><span id="line-311"></span><span class="hs-comment">-- This version uses the current state on entering the continuation.</span><span>
</span><span id="line-312"></span><span class="hs-comment">-- It does not satisfy the uniformity property (see &quot;Control.Monad.Signatures&quot;).</span><span>
</span><span id="line-313"></span><span id="local-6989586621679081539"><span id="local-6989586621679081540"><span id="local-6989586621679081541"><span id="local-6989586621679081542"><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#liftCallCC%27"><span class="hs-identifier hs-type">liftCallCC'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Control.Monad.Signatures.html#CallCC"><span class="hs-identifier hs-type">CallCC</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081542"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679081541"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621679081540"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679081539"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621679081540"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Signatures.html#CallCC"><span class="hs-identifier hs-type">CallCC</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081540"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081542"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><a href="#local-6989586621679081541"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081539"><span class="hs-identifier hs-type">b</span></a></span></span></span></span></span><span>
</span><span id="line-314"></span><span id="liftCallCC%27"><span class="annot"><span class="annottext">liftCallCC' :: forall (m :: * -&gt; *) a s b.
CallCC m (a, s) (b, s) -&gt; CallCC (StateT s m) a b
</span><a href="Control.Monad.Trans.State.Strict.html#liftCallCC%27"><span class="hs-identifier hs-var hs-var">liftCallCC'</span></a></span></span><span> </span><span id="local-6989586621679081538"><span class="annot"><span class="annottext">CallCC m (a, s) (b, s)
</span><a href="#local-6989586621679081538"><span class="hs-identifier hs-var">callCC</span></a></span></span><span> </span><span id="local-6989586621679081537"><span class="annot"><span class="annottext">(a -&gt; StateT s m b) -&gt; StateT s m a
</span><a href="#local-6989586621679081537"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(s -&gt; m (a, s)) -&gt; StateT s m a
forall s (m :: * -&gt; *) a. (s -&gt; m (a, s)) -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-var">StateT</span></a></span><span> </span><span class="annot"><span class="annottext">((s -&gt; m (a, s)) -&gt; StateT s m a)
-&gt; (s -&gt; m (a, s)) -&gt; StateT s m a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679081536"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081536"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-315"></span><span>    </span><span class="annot"><span class="annottext">CallCC m (a, s) (b, s)
</span><a href="#local-6989586621679081538"><span class="hs-identifier hs-var">callCC</span></a></span><span> </span><span class="annot"><span class="annottext">CallCC m (a, s) (b, s) -&gt; CallCC m (a, s) (b, s)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679081535"><span class="annot"><span class="annottext">(a, s) -&gt; m (b, s)
</span><a href="#local-6989586621679081535"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-316"></span><span>    </span><span class="annot"><span class="annottext">StateT s m a -&gt; s -&gt; m (a, s)
forall s (m :: * -&gt; *) a. StateT s m a -&gt; s -&gt; m (a, s)
</span><a href="Control.Monad.Trans.State.Strict.html#runStateT"><span class="hs-identifier hs-var hs-var">runStateT</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(a -&gt; StateT s m b) -&gt; StateT s m a
</span><a href="#local-6989586621679081537"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679081534"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679081534"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(s -&gt; m (b, s)) -&gt; StateT s m b
forall s (m :: * -&gt; *) a. (s -&gt; m (a, s)) -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-var">StateT</span></a></span><span> </span><span class="annot"><span class="annottext">((s -&gt; m (b, s)) -&gt; StateT s m b)
-&gt; (s -&gt; m (b, s)) -&gt; StateT s m b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679081533"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081533"><span class="hs-identifier hs-var">s'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(a, s) -&gt; m (b, s)
</span><a href="#local-6989586621679081535"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679081534"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081533"><span class="hs-identifier hs-var">s'</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081536"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-317"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#liftCallCC%27"><span class="hs-pragma hs-type">liftCallCC'</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-318"></span><span>
</span><span id="line-319"></span><span class="hs-comment">-- | Lift a @catchE@ operation to the new monad.</span><span>
</span><span id="line-320"></span><span id="local-6989586621679081828"><span id="local-6989586621679081829"><span id="local-6989586621679081830"><span id="local-6989586621679081831"><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#liftCatch"><span class="hs-identifier hs-type">liftCatch</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Control.Monad.Signatures.html#Catch"><span class="hs-identifier hs-type">Catch</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081831"><span class="hs-identifier hs-type">e</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081830"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679081829"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621679081828"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Signatures.html#Catch"><span class="hs-identifier hs-type">Catch</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081831"><span class="hs-identifier hs-type">e</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081828"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081830"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><a href="#local-6989586621679081829"><span class="hs-identifier hs-type">a</span></a></span></span></span></span></span><span>
</span><span id="line-321"></span><span id="liftCatch"><span class="annot"><span class="annottext">liftCatch :: forall e (m :: * -&gt; *) a s.
Catch e m (a, s) -&gt; Catch e (StateT s m) a
</span><a href="Control.Monad.Trans.State.Strict.html#liftCatch"><span class="hs-identifier hs-var hs-var">liftCatch</span></a></span></span><span> </span><span id="local-6989586621679081532"><span class="annot"><span class="annottext">Catch e m (a, s)
</span><a href="#local-6989586621679081532"><span class="hs-identifier hs-var">catchE</span></a></span></span><span> </span><span id="local-6989586621679081531"><span class="annot"><span class="annottext">StateT s m a
</span><a href="#local-6989586621679081531"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621679081530"><span class="annot"><span class="annottext">e -&gt; StateT s m a
</span><a href="#local-6989586621679081530"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-322"></span><span>    </span><span class="annot"><span class="annottext">(s -&gt; m (a, s)) -&gt; StateT s m a
forall s (m :: * -&gt; *) a. (s -&gt; m (a, s)) -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-var">StateT</span></a></span><span> </span><span class="annot"><span class="annottext">((s -&gt; m (a, s)) -&gt; StateT s m a)
-&gt; (s -&gt; m (a, s)) -&gt; StateT s m a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679081529"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081529"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">StateT s m a -&gt; s -&gt; m (a, s)
forall s (m :: * -&gt; *) a. StateT s m a -&gt; s -&gt; m (a, s)
</span><a href="Control.Monad.Trans.State.Strict.html#runStateT"><span class="hs-identifier hs-var hs-var">runStateT</span></a></span><span> </span><span class="annot"><span class="annottext">StateT s m a
</span><a href="#local-6989586621679081531"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081529"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="annot"><span class="annottext">Catch e m (a, s)
</span><a href="#local-6989586621679081532"><span class="hs-operator hs-var">`catchE`</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679081528"><span class="annot"><span class="annottext">e
</span><a href="#local-6989586621679081528"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">StateT s m a -&gt; s -&gt; m (a, s)
forall s (m :: * -&gt; *) a. StateT s m a -&gt; s -&gt; m (a, s)
</span><a href="Control.Monad.Trans.State.Strict.html#runStateT"><span class="hs-identifier hs-var hs-var">runStateT</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">e -&gt; StateT s m a
</span><a href="#local-6989586621679081530"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">e
</span><a href="#local-6989586621679081528"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081529"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-323"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#liftCatch"><span class="hs-pragma hs-type">liftCatch</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-324"></span><span>
</span><span id="line-325"></span><span class="hs-comment">-- | Lift a @listen@ operation to the new monad.</span><span>
</span><span id="line-326"></span><span id="local-6989586621679081819"><span id="local-6989586621679081820"><span id="local-6989586621679081821"><span id="local-6989586621679081822"><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#liftListen"><span class="hs-identifier hs-type">liftListen</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081822"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Signatures.html#Listen"><span class="hs-identifier hs-type">Listen</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081821"><span class="hs-identifier hs-type">w</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081822"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679081820"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621679081819"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Signatures.html#Listen"><span class="hs-identifier hs-type">Listen</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081821"><span class="hs-identifier hs-type">w</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081819"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081822"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><a href="#local-6989586621679081820"><span class="hs-identifier hs-type">a</span></a></span></span></span></span></span><span>
</span><span id="line-327"></span><span id="liftListen"><span class="annot"><span class="annottext">liftListen :: forall (m :: * -&gt; *) w a s.
Monad m =&gt;
Listen w m (a, s) -&gt; Listen w (StateT s m) a
</span><a href="Control.Monad.Trans.State.Strict.html#liftListen"><span class="hs-identifier hs-var hs-var">liftListen</span></a></span></span><span> </span><span id="local-6989586621679081524"><span class="annot"><span class="annottext">Listen w m (a, s)
</span><a href="#local-6989586621679081524"><span class="hs-identifier hs-var">listen</span></a></span></span><span> </span><span id="local-6989586621679081523"><span class="annot"><span class="annottext">StateT s m a
</span><a href="#local-6989586621679081523"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(s -&gt; m ((a, w), s)) -&gt; StateT s m (a, w)
forall s (m :: * -&gt; *) a. (s -&gt; m (a, s)) -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-var">StateT</span></a></span><span> </span><span class="annot"><span class="annottext">((s -&gt; m ((a, w), s)) -&gt; StateT s m (a, w))
-&gt; (s -&gt; m ((a, w), s)) -&gt; StateT s m (a, w)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679081522"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081522"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-328"></span><span>    </span><span class="hs-special">(</span><span class="hs-special">(</span><span id="local-6989586621679081521"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679081521"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679081520"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081520"><span class="hs-identifier hs-var">s'</span></a></span></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span id="local-6989586621679081519"><span class="annot"><span class="annottext">w
</span><a href="#local-6989586621679081519"><span class="hs-identifier hs-var">w</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Listen w m (a, s)
</span><a href="#local-6989586621679081524"><span class="hs-identifier hs-var">listen</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">StateT s m a -&gt; s -&gt; m (a, s)
forall s (m :: * -&gt; *) a. StateT s m a -&gt; s -&gt; m (a, s)
</span><a href="Control.Monad.Trans.State.Strict.html#runStateT"><span class="hs-identifier hs-var hs-var">runStateT</span></a></span><span> </span><span class="annot"><span class="annottext">StateT s m a
</span><a href="#local-6989586621679081523"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081522"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-329"></span><span>    </span><span class="annot"><span class="annottext">((a, w), s) -&gt; m ((a, w), s)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679081521"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">w
</span><a href="#local-6989586621679081519"><span class="hs-identifier hs-var">w</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081520"><span class="hs-identifier hs-var">s'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-330"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#liftListen"><span class="hs-pragma hs-type">liftListen</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-331"></span><span>
</span><span id="line-332"></span><span class="hs-comment">-- | Lift a @pass@ operation to the new monad.</span><span>
</span><span id="line-333"></span><span id="local-6989586621679081810"><span id="local-6989586621679081811"><span id="local-6989586621679081812"><span id="local-6989586621679081813"><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#liftPass"><span class="hs-identifier hs-type">liftPass</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081813"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Signatures.html#Pass"><span class="hs-identifier hs-type">Pass</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081812"><span class="hs-identifier hs-type">w</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081813"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679081811"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621679081810"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Signatures.html#Pass"><span class="hs-identifier hs-type">Pass</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081812"><span class="hs-identifier hs-type">w</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081810"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679081813"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><a href="#local-6989586621679081811"><span class="hs-identifier hs-type">a</span></a></span></span></span></span></span><span>
</span><span id="line-334"></span><span id="liftPass"><span class="annot"><span class="annottext">liftPass :: forall (m :: * -&gt; *) w a s.
Monad m =&gt;
Pass w m (a, s) -&gt; Pass w (StateT s m) a
</span><a href="Control.Monad.Trans.State.Strict.html#liftPass"><span class="hs-identifier hs-var hs-var">liftPass</span></a></span></span><span> </span><span id="local-6989586621679081515"><span class="annot"><span class="annottext">Pass w m (a, s)
</span><a href="#local-6989586621679081515"><span class="hs-identifier hs-var">pass</span></a></span></span><span> </span><span id="local-6989586621679081514"><span class="annot"><span class="annottext">StateT s m (a, w -&gt; w)
</span><a href="#local-6989586621679081514"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(s -&gt; m (a, s)) -&gt; StateT s m a
forall s (m :: * -&gt; *) a. (s -&gt; m (a, s)) -&gt; StateT s m a
</span><a href="Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-var">StateT</span></a></span><span> </span><span class="annot"><span class="annottext">((s -&gt; m (a, s)) -&gt; StateT s m a)
-&gt; (s -&gt; m (a, s)) -&gt; StateT s m a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679081513"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081513"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Pass w m (a, s)
</span><a href="#local-6989586621679081515"><span class="hs-identifier hs-var">pass</span></a></span><span> </span><span class="annot"><span class="annottext">Pass w m (a, s) -&gt; Pass w m (a, s)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-335"></span><span>    </span><span class="hs-special">(</span><span class="hs-special">(</span><span id="local-6989586621679081512"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679081512"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679081511"><span class="annot"><span class="annottext">w -&gt; w
</span><a href="#local-6989586621679081511"><span class="hs-identifier hs-var">f</span></a></span></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span id="local-6989586621679081510"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081510"><span class="hs-identifier hs-var">s'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">StateT s m (a, w -&gt; w) -&gt; s -&gt; m ((a, w -&gt; w), s)
forall s (m :: * -&gt; *) a. StateT s m a -&gt; s -&gt; m (a, s)
</span><a href="Control.Monad.Trans.State.Strict.html#runStateT"><span class="hs-identifier hs-var hs-var">runStateT</span></a></span><span> </span><span class="annot"><span class="annottext">StateT s m (a, w -&gt; w)
</span><a href="#local-6989586621679081514"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081513"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-336"></span><span>    </span><span class="annot"><span class="annottext">((a, s), w -&gt; w) -&gt; m ((a, s), w -&gt; w)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679081512"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679081510"><span class="hs-identifier hs-var">s'</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">w -&gt; w
</span><a href="#local-6989586621679081511"><span class="hs-identifier hs-var">f</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-337"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.State.Strict.html#liftPass"><span class="hs-pragma hs-type">liftPass</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-338"></span><span>
</span><span id="line-339"></span><span class="hs-comment">{- $examples

Parser from ParseLib with Hugs:

&gt; type Parser a = StateT String [] a
&gt;    ==&gt; StateT (String -&gt; [(a,String)])

For example, item can be written as:

&gt; item = do (x:xs) &lt;- get
&gt;        put xs
&gt;        return x
&gt;
&gt; type BoringState s a = StateT s Identity a
&gt;      ==&gt; StateT (s -&gt; Identity (a,s))
&gt;
&gt; type StateWithIO s a = StateT s IO a
&gt;      ==&gt; StateT (s -&gt; IO (a,s))
&gt;
&gt; type StateWithErr s a = StateT s Maybe a
&gt;      ==&gt; StateT (s -&gt; Maybe (a,s))

-}</span><span>
</span><span id="line-362"></span><span>
</span><span id="line-363"></span><span class="hs-comment">{- $counting

A function to increment a counter.
Taken from the paper \&quot;Generalising Monads to Arrows\&quot;,
John Hughes (&lt;http://www.cse.chalmers.se/~rjmh/&gt;), November 1998:

&gt; tick :: State Int Int
&gt; tick = do n &lt;- get
&gt;           put (n+1)
&gt;           return n

Add one to the given number using the state monad:

&gt; plusOne :: Int -&gt; Int
&gt; plusOne n = execState tick n

A contrived addition example. Works only with positive numbers:

&gt; plus :: Int -&gt; Int -&gt; Int
&gt; plus n x = execState (sequence $ replicate n tick) x

-}</span><span>
</span><span id="line-385"></span><span>
</span><span id="line-386"></span><span class="hs-comment">{- $labelling

An example from /The Craft of Functional Programming/, Simon
Thompson (&lt;http://www.cs.kent.ac.uk/people/staff/sjt/&gt;),
Addison-Wesley 1999: \&quot;Given an arbitrary tree, transform it to a
tree of integers in which the original elements are replaced by
natural numbers, starting from 0.  The same element has to be
replaced by the same number at every occurrence, and when we meet
an as-yet-unvisited element we have to find a \'new\' number to match
it with:\&quot;

&gt; data Tree a = Nil | Node a (Tree a) (Tree a) deriving (Show, Eq)
&gt; type Table a = [a]

&gt; numberTree :: Eq a =&gt; Tree a -&gt; State (Table a) (Tree Int)
&gt; numberTree Nil = return Nil
&gt; numberTree (Node x t1 t2) = do
&gt;     num &lt;- numberNode x
&gt;     nt1 &lt;- numberTree t1
&gt;     nt2 &lt;- numberTree t2
&gt;     return (Node num nt1 nt2)
&gt;   where
&gt;     numberNode :: Eq a =&gt; a -&gt; State (Table a) Int
&gt;     numberNode x = do
&gt;         table &lt;- get
&gt;         case elemIndex x table of
&gt;             Nothing -&gt; do
&gt;                 put (table ++ [x])
&gt;                 return (length table)
&gt;             Just i -&gt; return i

numTree applies numberTree with an initial state:

&gt; numTree :: (Eq a) =&gt; Tree a -&gt; Tree Int
&gt; numTree t = evalState (numberTree t) []

&gt; testTree = Node &quot;Zero&quot; (Node &quot;One&quot; (Node &quot;Two&quot; Nil Nil) (Node &quot;One&quot; (Node &quot;Zero&quot; Nil Nil) Nil)) Nil
&gt; numTree testTree =&gt; Node 0 (Node 1 (Node 2 Nil Nil) (Node 1 (Node 0 Nil Nil) Nil)) Nil

-}</span><span>
</span><span id="line-426"></span></pre></body></html>